import request from '@/router/axios';
import { baseUrl } from '@/config/env';
const scope = 'test'
export const loginByUsername = (username, password, redomStr) => {
    const grant_type = 'password'
    return request({
        url:  baseUrl + '/auth/oauth/token',
        headers: {
            isToken:false,
            'Authorization': 'Basic dGVzdDp0ZXN0'
        },
        method: 'post',
        params: { username, password, redomStr, grant_type, scope }
    })
}


export const refreshToken = (refresh_token) => {
    const grant_type = 'refresh_token'
    return request({
        url: '/auth/oauth/token',
        headers: {
            'isToken': false,
            'Authorization': 'Basic dGVzdDp0ZXN0',
        },
        method: 'post',
        params: { refresh_token, grant_type, scope }
    })
}



export const logout = () => request({
    url: baseUrl + '/user/logout',
    method: 'get'
})
